package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;

public class LCMP extends Instruction {
	public  void readindex(ByteBuffer reader) {
		//no need to read
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
		int high=(int) stack[top-1];
		int low =(int) stack[top-2];
		long value2=(((long) high) << 32) | ((long) low & 0x0ffffffffL);
		top=top-2;
	    high=(int) stack[top-1];
		low =(int) stack[top-2];
		long value1=(((long) high) << 32) | ((long) low & 0x0ffffffffL);
		top=top-2;
		if (value1>value2) {
			stack[top]=1;
		}else if (value1==value2) {
			stack[top]=0;
		}else {
			stack[top]=-1;
		}
		top++;
		frame.setManagestack(stack);
		frame.setStacktop(top);
	}
}
